#ifndef CLIENTCONNECTION_H
#define CLIENTCONNECTION_H

#include "connection.h"
#include "connectionplayer.h"
#include "packet.h"

class ClientConnection : public ConnectionPlayer
{
    Q_OBJECT
public:
    ClientConnection(QHostAddress a, quint16 p, bool onlyReceive = false);
    ClientConnection(bool onlyReceive = false);

    void connectToServer();
    void disconnectFromServer();
    void sendShootMsg(qreal x, qreal y, qint32 angle);
private:
    QHash<quint32,ConnectionPlayer*> connectionHash;

    void runCommand(PacketData* data, bool isNewestPacket);

    void doHELLO(PacketData* data);
    void doPING(PacketData* data);
    void doJOIN(PacketData* data);
    void doLIST(PacketData* data);
    void doQUIT(PacketData* data);
    void doDISCONNECT(PacketData* data);
    void doSTATE(PacketData* data);
    void doSHOOT(PacketData* data);

private slots:
	void sendState();

signals:
   void newPlayerConnected(ConnectionPlayer* conn);
   void playerDisconnected(qint32 id);
};

#endif // CLIENTCONNECTION_H
